package com.example.dmo.controller;

import com.example.dmo.model.DBType;
import com.example.dmo.model.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PostConstruct;

@RestController
public class YmlController {
    @Value("${demo.key1}")
    private String key1;

    @Value("${demo.key2}")
    private String key2;

    @Value("${demo.key3}")
    private String key3;

    @Value("${string.str1}")
    private String str1;

    @Value("${string.str2}")
    private String str2;

    @Value("${string.str3}")
    private String str3;

    @Autowired
    public Student student;

    @Autowired
    public DBType dbType;

    @RequestMapping("/readYml")
    public String readYml(){
        return "读取到的配置项key1:"+key1;
    }
    @PostConstruct//打印到控制台
    public void init(){
        /*System.out.println("读取到的配置项key1:"+key1);
        System.out.println("读取到的配置项key2:"+key2);
        System.out.println("读取到的配置项key3:"+key3);
        System.out.println(str1);
        System.out.println(str2);
        System.out.println(str3);*/

        System.out.println("student:"+student);
        System.out.println("dbType:"+dbType);
    }
}
